# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# openUBMC is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#         http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
import os
from conan import ConanFile
from conan.tools.scm import Git
from conan.tools.files import copy
from conan.tools.files import apply_conandata_patches, export_conandata_patches

required_conan_version = ">=2.13.0"


class LuacovConan(ConanFile):
    name = "luacov"
    license = "Mulan PSL v2"
    description = "LuaCov is a simple coverage analyzer for Lua code."
    settings = "os", "arch", "compiler"
    
    def source(self):
        git = Git(self)
        git.fetch_commit(url=self.conan_data["sources"][self.version]["url"], commit=self.conan_data["sources"][self.version]["branch"])

    def export_sources(self):
        export_conandata_patches(self)

    def build(self):
        apply_conandata_patches(self)

    def package(self):
        copy(self, "*", src="src", dst=os.path.join(self.package_folder, "opt/bmc/lualib/luacov"))
